from dataclasses import dataclass


@dataclass  # 使用@dataclass装饰器自动生成__init__等方法
class CaseInfo:
    feature: str
    story: str
    title: str
    request: dict
    validate: dict

    # 校验测试用例


def verify_yaml(caseinfo: dict):
    new_caseinfo = CaseInfo(**caseinfo)  # 字典解包转换为对象
    return new_caseinfo


if __name__ == '__main__':
    a = {'feature': '论坛模块',
         'story': 'phpwind模块接口',
         'title': '验证pip接口正常返回',
         'request': {
             'method': 'post',
             'url': 'http://101.34.221.219:8010/api.php',
             'params': {'s': 'index/index'}},
         'validate': None
         }
    new_caseinfo = verify_yaml(a)
    print(new_caseinfo.feature)
    print(new_caseinfo.title)
    print(new_caseinfo.request)
